package com.fbs.wowo.forum.mapper;

import com.fbs.wowo.forum.entity.Comments;
import org.apache.ibatis.jdbc.SQL;

public class CommentsSqlProvider {

    public String insertSelective(Comments record) {
        SQL sql = new SQL();
        sql.INSERT_INTO("comments");
        
        if (record.getId() != null) {
            sql.VALUES("id", "#{id,jdbcType=VARCHAR}");
        }
        
        if (record.getCommentEntity() != null) {
            sql.VALUES("comment_entity", "#{commentEntity,jdbcType=VARCHAR}");
        }
        
        if (record.getCommentType() != null) {
            sql.VALUES("comment_type", "#{commentType,jdbcType=INTEGER}");
        }
        
        if (record.getCommentTime() != null) {
            sql.VALUES("comment_time", "#{commentTime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getUserId() != null) {
            sql.VALUES("user_id", "#{userId,jdbcType=VARCHAR}");
        }
        
        if (record.getStatus() != null) {
            sql.VALUES("status", "#{status,jdbcType=INTEGER}");
        }
        
        if (record.getContent() != null) {
            sql.VALUES("content", "#{content,jdbcType=LONGVARCHAR}");
        }
        
        return sql.toString();
    }

    public String updateByPrimaryKeySelective(Comments record) {
        SQL sql = new SQL();
        sql.UPDATE("comments");
        
        if (record.getCommentEntity() != null) {
            sql.SET("comment_entity = #{commentEntity,jdbcType=VARCHAR}");
        }
        
        if (record.getCommentType() != null) {
            sql.SET("comment_type = #{commentType,jdbcType=INTEGER}");
        }
        
        if (record.getCommentTime() != null) {
            sql.SET("comment_time = #{commentTime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getUserId() != null) {
            sql.SET("user_id = #{userId,jdbcType=VARCHAR}");
        }
        
        if (record.getStatus() != null) {
            sql.SET("status = #{status,jdbcType=INTEGER}");
        }
        
        if (record.getContent() != null) {
            sql.SET("content = #{content,jdbcType=LONGVARCHAR}");
        }
        
        sql.WHERE("id = #{id,jdbcType=VARCHAR}");
        
        return sql.toString();
    }
}